package com.yunxin.core.infra.persistence.repository.user;

import com.yunxin.core.domain.model.user.UserLoginRecord;
import com.yunxin.core.domain.model.user.UserLoginRecordRepository;
import com.yunxin.core.infra.persistence.converter.UserInfoConverter;
import com.yunxin.core.infra.persistence.entity.user.UserLoginRecordDO;
import com.yunxin.core.infra.persistence.mapper.user.UserLoginRecordExtendMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;

/**
 * @author zero°
 * @since 2023-07-13
 */
@Repository
@RequiredArgsConstructor
public class UserLoginRecordRepositoryImpl implements UserLoginRecordRepository {

    private final UserLoginRecordExtendMapper userLoginRecordExtendMapper;

    private final UserInfoConverter userInfoConverter;

    @Override
    public boolean saveUserLoginRecord(UserLoginRecord userLoginRecord) {
        UserLoginRecordDO userLoginRecordDO = userInfoConverter.formUserLoginRecord(userLoginRecord);
        int count = userLoginRecordExtendMapper.insertSelective(userLoginRecordDO);
        return count > 0;
    }
}
